package com.android.settings.audio.peq.qr.encoder;


import static com.android.settings.audio.peq.qr.Constant.QR_SCHEMA_V1_MSEB;

import com.google.gson.Gson;
import com.android.settings.audio.peq.qr.QrManager;
import com.android.settings.audio.peq.qr.annotation.QrImpl;
import com.android.settings.audio.peq.soundeffect.PluginDataManager;

/**
 * Created by We on 2023/5/25
 */
@QrImpl(id = QR_SCHEMA_V1_MSEB)
public class MsebV1Encoder extends QrManager.AbsEncoder {
    public MsebV1Encoder() {
        this.id = QR_SCHEMA_V1_MSEB; //by inject
    }

    @Override
    public String generateContent(byte[] data) {
        return this.id + new String(data);
    }

    @Override
    public byte[] toBytes(Object dataEntity) throws Exception {
        PluginDataManager.MsebData msebData = (PluginDataManager.MsebData) dataEntity;
        return new Gson().toJson(msebData).getBytes();
    }
}
